package vashion.azeroth.api.controller.biz;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import vashion.azeroth.api.controller.base.BaseController;
import vashion.azeroth.biz.GoodItemService;
import vashion.azeroth.core.biz.BrandVO;
import vashion.azeroth.core.biz.GoodItemVO;
import vashion.azeroth.core.item.pojo.ForestDO;
import vashion.azeroth.core.result.ApiResult;

import java.util.List;

/**
 * 好物restful接口
 *
 * @param <T>
 */
@Controller
@RequestMapping("/api/gooditem")
public class GoodItemController<T> extends BaseController {

    private final static Logger log = LoggerFactory.getLogger(GoodItemController.class);

    @Autowired
    private GoodItemService goodItemService;


    @RequestMapping("getGoodsInfo.htm")
    @ResponseBody
    public ApiResult<GoodItemVO> getGoodsInfo(@RequestParam(value = "needBanner", required = false) Boolean needBanner,
                                              @RequestParam(value = "start", required = false) Integer start,
                                              @RequestParam(value = "pageSize", required = false) Integer pageSize) {


        return goodItemService.getGoodsInfo(null == needBanner ? false : needBanner,
                null == start ? 0 : start,
                null == pageSize ? 10 : pageSize);
    }


    @RequestMapping("getChildForestList.htm")
    @ResponseBody
    public ApiResult<List<ForestDO>> getChildForestList() {
        return goodItemService.getChildForestList();
    }

    @RequestMapping("getOldBrandList.htm")
    @ResponseBody
    public ApiResult<List<BrandVO>> getBrandList() {
        return goodItemService.getBrandList();
    }

}
